const Router = require('koa-router')
const updategoods = new Router()
//！拿到前端的数据
//数据库连接池
const pg = require('pg');
let psql = new pg.Pool({
  database: 'running',
  user: 'run',
  port: 5432,
  host: '82.157.94.115',
  password: 'z12345678',
  max: 2
})

updategoods.post('/updategoods', async ctx => {
  // ctx.body = '首页文章推荐'
  let {goods_id,goods_name,goods_title,goods_price,goods_img} = ctx.request.body;
  console.log(goods_price)
  let updateContentPostgresql = `update goods set goods_name = '${goods_name}', goods_title = '${goods_title}',goods_price = '${goods_price}',goods_img='http://82.157.94.115:2009/static/images/1.jpg' where goods_id = '${goods_id}'`;
  let goods = await psql.query(updateContentPostgresql);
    ctx.body = {
        goods
    };
})

module.exports = updategoods